﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;

namespace Chinaer.Log
{
    public class Logger
    {
         static Logger()
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        public static void WriteErrorLog(string message, Exception ex)
        {
            ILog log = LogManager.GetLogger("error");
            log.Error(message, ex);
        }
        public static void WriteFatalLog(string message, Exception ex)
        {
            ILog log = LogManager.GetLogger("fatal");
            log.Error(message, ex);
        }
        public static void Error<T>(string message, Exception ex)
        {
            ILog log = LogManager.GetLogger(typeof(T));
            log.Error(message, ex);
        }

        public static void Debug<T>(string message)
        {
            ILog log = LogManager.GetLogger(typeof(T));
            log.Debug(message);
        }

        public void Debug<T>(string text, params object[] args)
        {
            ILog log = LogManager.GetLogger(typeof(T));
            log.Debug(String.Format(text, args));
        }

        public static void Info<T>(string message)
        {
            ILog log = LogManager.GetLogger(typeof(T));
            log.Info(message);
        }

        public void Info<T>(string text, params object[] args)
        {
            ILog log = LogManager.GetLogger(typeof(T));
            log.Info(String.Format(text, args));
        }
    }
}
